<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
	<meta content="telephone=no" name="format-detection"/>

<title>确认领取</title>
<link href="<%=path %>/css/stlye.css" rel="stylesheet" type="text/css" />
<style>
input{
     width:80%;
	 height:2rem;
	 font-size:1.3rem;
	 line-height:3rem;
	 text-align:center;
	 margin:0 auto;
	 background-color:#fff;
     border-radius:15px;
	 border:none;
	 }
</style>
<script type="text/javascript" src="<%=path %>/js/jquery-1.11.0.min.js"></script>
<script src="<%=path%>/js/plugins/layer/layer.js"></script>	
<script type="text/javascript">
	(function() {
		var el = document.createElement("STYLE");
		var docEl = document.documentElement;
		var portrait = ((Math.min(docEl.clientWidth, docEl.clientHeight) / 320) * 10);
		var landscape = ((Math.max(docEl.clientWidth, docEl.clientHeight) / 568) * 17.75);
		el.innerHTML = "@media screen and (orientation:portrait) { html { font-size: " + portrait + "px!important; } }\n@media screen and (orientation:landscape) { html { font-size: " + landscape + "px!important; } }";
		docEl.firstElementChild.appendChild(el);
	})();
	
	$(document).ready(function(){
		$("TEXTAREA,input[focucmsg]") .each (function(){
			$(this).val($(this).attr("focucmsg"));
			$(this).val($(this).attr("focucmsg")).css("color","#979393");
			$(this).focus(function(){
				if($(this).val() == $(this).attr("focucmsg"))
				{
					$(this).val('');
					$(this).val('').css("color","#6b6969");
				}
			});
			$(this).blur(function(){
				if(!$(this).val()){
					$(this).val($(this).attr("focucmsg"));
					$(this).val($(this).attr("focucmsg")).css("color","#979393");
				}
			});
		});
	});
	
	function editAddress(){
		var deliveryAddressId=$("#delivery_address_id").val();
		var goodsId=$("#goods_id").val();
		var selectProperty=$("#select_property").val();
		if(deliveryAddressId!=null&&deliveryAddressId!=''){
			window.location.href="<%=path%>/check/address/toUpdate/"+deliveryAddressId+"?goodsId="+goodsId+"&selectProperty="+selectProperty;
		}else{
			window.location.href="<%=path%>/check/address/toInsert?goodsId="+goodsId+"&selectProperty="+selectProperty;
		}
	}
	
	function toInvitaion(){
		window.location.href="<%=path%>/check/invitation/toInvit";		
	}
	
	function createTrade(){
		$.ajax({
			url : "<%=path%>/check/trade/create",
			type : "post",
			dataType : "json",
			data : $("#trade_create_form").serialize(),
			success : function(data)
			{
				if(data.result){
					layer.msg("创建订单成功",{icon: 1});
					window.location.href="<%=path%>/check/trade/payprocess?chargeId="+data.chargeId;
				}else{
					layer.msg(data.message,{icon: 2});
				}
			},error:function(){
				layer.msg("服务器网络繁忙",{icon: 2});
			}
		});
	}
</script>
</head>
<body style="background-color:#f2f2f2;">
<form action="javascript:void()" id="trade_create_form">
<input type="hidden" name="deliveryAddressId" id="delivery_address_id" value="${deliveryAddressVO.deliveryAddressId}">

<input type="hidden" name="contactName"  value="${deliveryAddressVO.contactName}">

<input type="hidden" name="contactPhone"  value="${deliveryAddressVO.contactPhone}">

<input type="hidden" name="deliveryProvince"  value="${deliveryAddressVO.deliveryProvince}">

<input type="hidden" name="deliveryCity"  value="${deliveryAddressVO.deliveryCity}">

<input type="hidden" name="deliveryRegion"  value="${deliveryAddressVO.deliveryRegion}">

<input type="hidden" name="deliveryAddress"  value="${deliveryAddressVO.deliveryAddress}">

<input type="hidden" name="goodsId" id="goods_id" value="${goods.goodsId}">

<input type="hidden" name="couponId" id="coupon_id" value="${couponVO.couponId}">

<input type="hidden" name="selectProperty" id="select_property" value="${selectProperty}">

<div class="jg" style="background-color:#f3f3f3; height:1.5rem;;"></div>
<div class="dizhi_top" onclick="editAddress()">
   <div class="dizhi_top_biaot">
      <p>收货地址</p>
      <em>更改</em>
   </div>
   <div class="dizhi_top_xinxi">
      <div class="dizhi_top_shouhuoren">
       <p>收货人:</p>
       <em>${deliveryAddressVO.contactName}</em>
      </div>
      <div class="dizhi_top_shouji">
       <p>手机号码：</p>
       <em>${deliveryAddressVO.contactPhone}</em>
      </div>
      <div class="clear"></div>
         <div class="dizhi_top_dizhi">
       <p>收货地址：</p>
       <em>${deliveryAddressVO.deliveryProvince}${deliveryAddressVO.deliveryCity}${deliveryAddressVO.deliveryRegion}${deliveryAddressVO.deliveryAddress}</em>
      </div>      
   </div>
</div>

<div class="queren_inherit">
	<dl>
		<dt>
			<img src="<%=path %>/uncheck/pictures/servlet?id=${goods.goodsSmallImg}"  width="100%" height=""/>
		</dt>
		<dd >
			${goods.goodsDetail}
		</dd>
		<h1>商品${propertiesName}:${selectProperty}</h1>
		<dd>
		<h3 style="text-decoration:line-through;">原价：￥${goods.goodsPrice}</h3>
		<h4>现价：0元</h4>
		<h5>已领取${goods.buyNum}人次</h5>
		</dd>
	</dl>
</div>

<c:choose>
<c:when test="${not empty couponVO.couponNo}">

<div class="queren_peisong">
   <div class="queren_peisong_top">
     <p>配送方式</p>
     <em>快递寄送</em>
   </div>
   <div class="queren_peisong_inherit">
     <em>${tradeAmount}</em>
     <p>手工运费</p>
     <span>￥</span>
   </div>
   <c:if test="${exDeliveryFee>0}">
   <div class="queren_peisong_inherit">
     <em>${exDeliveryFee}</em>
     <p>${deliveryAddressVO.deliveryProvince}加收运费</p>
     <span>￥</span>
   </div>
   <div class="queren_peisong_inherit">
     <em>${tradeAmount+exDeliveryFee}</em>
     <p>总运费</p>
     <span>￥</span>
   </div>
   </c:if>
   <div class="queren_peisong_bottom">
     <p>留言:</p>
     <em><input type="text"  name="remark" value=""  focucmsg="留下您与我们要说的话" style="height:1.2rem; width:25rem; font-size:1rem; line-height:1.2rem;" /></em>
   </div>
</div>

<div class="duihuanm">
<input type="text" name="couponNo" value="${couponVO.couponNo}" readonly="readonly" style="height:2.8rem; width:100%; line-height:2.8rem;" >
</div>
<div class="querenbuttom" onclick="javascript:createTrade()">立即兑换</div>
</c:when>
<c:otherwise>
<div class="duihuanm">
<input type="text" name="couponNo" value="还没有优惠券" style="height:2.8rem; width:100%; line-height:2.6rem; font-size:1.2rem;" readonly="readonly">
</div>
<div class="querenbuttom" onclick="javascript:toInvitaion()">邀请得券</div>
</c:otherwise>
</c:choose>
</form>
<jsp:include page="/views/html5/commons/footer.jsp"></jsp:include>
</body>
</html>
